function DataSet(data, options) {
  // 定义空数组接收数据
  this._data = []; // map with data indexed by id
  if (data) {
    console.log(data, "dataSet data");
    console.log(options, "dataSet options");
    this.add(data);
  }
}
// 添加数据
DataSet.prototype.add = function(data) {
  if (Array.isArray(data)) {
    // 数组类型遍历添加数据
    // Array
    for (var i = 0, len = data.length; i < len; i++) {
      if (data[i]) {
        // 如果数据为按时间字段来动画展示数据，对时间格式进行处理
        if (
          data[i].time &&
          data[i].time.length == 14 &&
          data[i].time.substr(0, 2) == "20"
        ) {
          var time = data[i].time;
          data[i].time = new Date(
            time.substr(0, 4) +
              "-" +
              time.substr(4, 2) +
              "-" +
              time.substr(6, 2) +
              " " +
              time.substr(8, 2) +
              ":" +
              time.substr(10, 2) +
              ":" +
              time.substr(12, 2)
          ).getTime();
        }
        // 空数组内添加传入参数数据
        this._data.push(data[i]);
      }
    }
  } else if (data instanceof Object) {
    // 对象类型直接添加数据
    // Single item
    this._data.push(data);
  } else {
    // 未知类型，抛出错误
    throw new Error("Unknown dataType");
  }
  // 拷贝一份数据进行缓存
  this._dataCache = JSON.parse(JSON.stringify(this._data));
};
// 获取数据   可通过dataSet.get()获取当前数据集的数据，也可通过filter参数获取过滤后的数据
DataSet.prototype.get = function(args) {
  // 获取传入参数
  args = args || {};

  //console.time('copy data time')
  // TODO: 不修改原始数据，在数据上挂载新的名称，每次修改数据直接修改新名称下的数据，可以省去deepCopy
  // var data = deepCopy(this._data);
  var data = this._data;

  if (args.filter) {
    var newData = [];
    for (var i = 0; i < data.length; i++) {
      if (args.filter(data[i])) {
        newData.push(data[i]);
      }
    }
    // 过滤数据后进行赋值
    data = newData;
  }
  // 如果有改变坐标系参数
  if (args.transferCoordinate) {
    data = this.transferCoordinate(
      data,
      args.transferCoordinate,
      args.fromColumn,
      args.toColumn
    );
  }

  // console.timeEnd('transferCoordinate time')
  // 不操作源数据，操作返回拷贝数据
  return data;
};
/**
 * transfer coordinate.
 */
DataSet.prototype.transferCoordinate = function(
  data,
  transferFn,
  fromColumn,
  toColumnName
) {
  toColumnName = toColumnName || "_coordinates";
  fromColumn = fromColumn || "coordinates";

  for (var i = 0; i < data.length; i++) {
    var geometry = data[i].geometry;
    // 坐标点
    var coordinates = geometry[fromColumn];
    // 根据不同的地理数据类型，区分处理方法
    switch (geometry.type) {
      case "Point":
        geometry[toColumnName] = transferFn(coordinates);
        break;
      case "LineString":
        var newCoordinates = [];
        for (var j = 0; j < coordinates.length; j++) {
          newCoordinates.push(transferFn(coordinates[j]));
        }
        geometry[toColumnName] = newCoordinates;
        break;
      case "MultiLineString":
      case "Polygon":
        newCoordinates = getPolygon(coordinates);
        geometry[toColumnName] = newCoordinates;
        break;
      case "MultiPolygon":
        newCoordinates = [];
        for (var c = 0; c < coordinates.length; c++) {
          var polygon = coordinates[c];
          polygon = getPolygon(polygon);
          newCoordinates.push(polygon);
        }

        geometry[toColumnName] = newCoordinates;
        break;
    }
  }

  function getPolygon(coordinates) {
    var newCoordinates = [];
    for (var c = 0; c < coordinates.length; c++) {
      var coordinate = coordinates[c];
      var newcoordinate = [];
      for (var j = 0; j < coordinate.length; j++) {
        newcoordinate.push(transferFn(coordinate[j]));
      }
      newCoordinates.push(newcoordinate);
    }
    return newCoordinates;
  }

  return data;
};
/**
 * set data.
 */
DataSet.prototype._set = function(data) {
  // 清空数据
  this.clear();
  // 调用添加数据方法
  this.add(data);
};
/**
 * clear data.
 */
DataSet.prototype.clear = function() {
  this._data = []; // map with data indexed by id
};

export default DataSet;
